Skip to content

fix(simd): gate simd_avx512 tests behind target_feature = avx512f#134

Merged
AdaWorldAPI merged 1 commit intomasterfrom
cursor/gate-avx512-tests-9e6d
May 2, 2026
Merged

fix(simd): gate simd_avx512 tests behind target_feature = avx512f#134
AdaWorldAPI merged 1 commit intomasterfrom
cursor/gate-avx512-tests-9e6d

Conversation

@AdaWorldAPI
Copy link
Copy Markdown
Owner

Problem

CI tests 1746/1747 (simd_avx512::tier3_tests::movemask_all_high and movemask_all_zero) SIGILL on GitHub Actions runners (x86-64-v3, no AVX-512). This blocked 570 remaining tests from running.

Root cause: the 5 test modules in src/simd_avx512.rs call raw AVX-512 intrinsics (_mm512_movepi8_mask, _mm512_set1_epi8, etc.) directly, bypassing the simd.rs LazyLock polyfill. On non-AVX-512 hardware, these instructions are illegal.

Fix

Changed #[cfg(test)]#[cfg(all(test, target_feature = "avx512f"))] on all 5 test modules:

  • bf16_tests
  • f16_tests
  • u8x64_rasterizer_tests
  • tier3_tests
  • int_simd_tests

These tests now compile away entirely on x86-64-v3 (CI/Cloud). On consumer x86-64-v4 hardware, they still run as before.

Architecture context

The simd.rs LazyLock polyfill is the contract — consumers call crate::simd::F32x16 which dispatches to:

  • simd_avx512.rs native intrinsics on AVX-512 hardware
  • simd_avx2.rs emulation (two 256-bit ops or scalar fallbacks) on AVX2 hardware

Raw intrinsic tests in simd_avx512.rs must never run on CI/Cloud (x86-64-v3). The polyfill dispatch tests (simd_ops, simd_avx2) cover correctness on v3.

Verification

  • cargo build — clean
  • cargo clippy --features approx,serde,rayon -- -D warnings — clean
  • cargo test --lib -p ndarray1776 passed, 0 failed, 36 ignored (vs. previous 2 SIGILL + 570 blocked)
  • cargo test --lib -p ndarray -- simd_avx2 — 16 passed
  • cargo test --lib -p ndarray -- simd_ops — 11 passed
  • cargo run --example life — runs correctly

Also updated AGENTS.md with accurate test count and clarified AVX-512 gating rationale.

Open in Web Open in Cursor 

…avx512f

The 5 test modules in simd_avx512.rs (bf16_tests, f16_tests,
u8x64_rasterizer_tests, tier3_tests, int_simd_tests) call raw AVX-512
intrinsics directly. On CI/Cloud VMs running x86-64-v3 (AVX2 only),
movemask_all_high and movemask_all_zero SIGILL because _mm512_movepi8_mask
requires AVX-512BW hardware.

These tests should only compile and run on consumer x86-64-v4 hardware.
On v3, the simd.rs LazyLock polyfill dispatches to simd_avx2.rs emulations
which have matching scalar fallbacks for every 512-bit operation.

Changed: #[cfg(test)] → #[cfg(all(test, target_feature = "avx512f"))]
on all 5 test modules.

Test counts: 1776 pass / 0 fail / 36 ignored (non-AVX-512 VM)
Previously: 1819 tests, 2 SIGILL failures blocking 570 remaining tests

Co-authored-by: AdaWorldAPI <AdaWorldAPI@users.noreply.github.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2dd9c4f4e3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/simd_avx512.rs
}

#[cfg(test)]
#[cfg(all(test, target_feature = "avx512f"))]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep BF16/F16 correctness tests in default test builds

This cfg gate now compiles out the entire bf16_tests module unless AVX-512 is enabled at compile time, but that module contains scalar and runtime-dispatched checks (for example scalar_roundtrip and batch_conversion_matches_scalar) that should still run on non-AVX-512 hosts. In normal cargo test runs (without -C target-feature=+avx512f), these core conversion tests disappear, so CI no longer validates BF16/F16 correctness on the default x86_64 path.

Useful? React with 👍 / 👎.

Comment thread src/simd_avx512.rs
// ────────────────────────────────────────────────────────────────────────

#[cfg(test)]
#[cfg(all(test, target_feature = "avx512f"))]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Re-enable int SIMD tests for non-AVX512 dispatch path

Gating int_simd_tests on compile-time target_feature="avx512f" removes these tests from the default x86-64-v3/CI environment, even though the module tests crate::simd types that intentionally dispatch to AVX2/scalar implementations when AVX-512 is unavailable. That means regressions in the non-AVX512 path are no longer exercised by standard test runs.

Useful? React with 👍 / 👎.

@AdaWorldAPI AdaWorldAPI merged commit c779c5b into master May 2, 2026
8 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants